<?php
if($_FILES['uploadedfile']['name'] !="") {


$target_path = "/home/www/main/upload/submissions/";

if ($_POST['contest'] == "AI") {
    $target_path = $target_path . "ai/" . $_POST['handle'] . "_" . basename( $_FILES['uploadedfile']['name']);
} else {
    $target_path = $target_path . "gui/" . $_POST['handle'] . "_" . basename( $_FILES['uploadedfile']['name']);
}

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "File ".  basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    chmod($target_path, 0300);
} else{
    echo "There was an error uploading the file, please try again!";
}
exit();
}
?>


<h3>SAGA Fest Coding Contest Submission Page</h3>
<form enctype="mulitpart/form-data" action="index.php" method="POST">
<input type="radio" name="contest" value="AI" checked />Tower Defense AI<br />
<input type="radio" name="contest" value="GUI" />Tower Defense GUI<br /><br />
SAGA Handle&nbsp;<input type="text" name="handle"><br /><br />
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br /><br />
<input type="submit" value="Upload File" />
</form>
